<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fm" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%@include file="../header.jsp" %>
<script src="statics/calendar/WdatePicker.js"></script>
<script>
	$(function(){
		bindRole()
		bindEvent()
	})

	function bindRole(){
		$.get("listRole",function(msg){
			var str = "";
			var selectid = $("#roleid").val();
			$(msg).each(function(i){
				var r = msg[i]
				if(selectid == r.id){
					str += "<option value='"+r.id+"' selected='selected'>"
				}else{
					str += "<option value='"+r.id+"'>"
				}
				
				str += r.rolename
				str += "</option>"
			})
			$("#userRole").append(str)
		},"json");
	}
	
	function bindEvent(){
		$("#save").click(function(){
			
			//提交表单
			document.forms[0].submit();
		})
	}
</script>
 <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>用户管理页面 >> 用户修改页面</span>
        </div>
        <div class="providerAdd">
        <form id="userForm" name="userForm" method="post" action="updateUser" enctype="multipart/form-data">
			<input type="hidden" name="id" value="${requestScope.user.id }">
			 <div>
                    <label for="userName">用户编码：</label>
                    <input type="text" value="${requestScope.user.usercode }" readonly="readonly"> 
             </div>
			 <div>
                    <label for="userName">用户名称：</label>
                    <input type="text" name="username" id="userName" value="${requestScope.user.username }"> 
					<font color="red"></font>
             </div>
			 <div>
                    <label >用户性别：</label>
                    <select name="gender" id="gender">
						
						<option value="0" <c:if test="${requestScope.user.gender==0 }">selected="selected"</c:if>>男</option>
					    <option value="1" <c:if test="${requestScope.user.gender==1 }">selected="selected"</c:if>>女</option>
						
					 </select>
             </div>
			 <div>
                    <label for="data">出生日期：</label>
                    <input type="text" Class="Wdate" id="birthday" name="birthday" value="<fm:formatDate value="${requestScope.user.birthday }" pattern="yyyy-MM-dd"/>"
					readonly="readonly" onclick="WdatePicker();">
                    <font color="red"></font>
              </div>
			
		       <div>
                    <label for="userphone">用户电话：</label>
                    <input type="text" name="phone" id="phone" value="${requestScope.user.phone }"> 
                    <font color="red"></font>
               </div>
                <div>
                    <label for="userAddress">用户地址：</label>
                    <input type="text" name="address" id="address" value="${requestScope.user.address }">
                </div>
				<div>
                    <label >用户角色：</label>
                    <!-- 列出所有的角色分类 -->
					<input type="hidden" value="${requestScope.user.userrole.id }" id="roleid">
					<select name="userrole.id" id="userRole"></select>
        			<font color="red"></font>
                </div>
                <div>
                	<label for="m_idPicPath">证件照：</label>
                	
                   			<input type="file" name="cphoto" id="m_idPicPath"/>
                    		<font color="red"></font>
	            		
                </div>
               <div>
               	   <label for="m_workPicPath">工作证照片：</label>
	              
                   			<input type="file" name="wphoto" id="m_workPicPath"/>
                    		<font color="red"></font>
	            		
                </div>
			 <div class="providerAddBtn">
                    <input type="button" name="save" id="save" value="保存" />
                    <input type="button" id="back" name="back" value="返回"/>
                </div>
            </form>
        </div>
    </div>
</section>

<%@include file="../foot.jsp" %>
